# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Renato Silva <br.renatosilva@gmail.com>
# Contributor: Karlson2k (Evgeny Grin) <k2k@narod.ru>
# Contributor: Alethea Rose <alethea@alethearose.com>

pkgname=filesystem
pkgver=2018.12
pkgrel=1
pkgdesc='Base filesystem'
arch=('i686' 'x86_64')
license=('BSD')
url='https://sourceforge.net/projects/msys2/'
groups=('base')
provides=('msys2-base')
replaces=('msys2-base')
backup=('etc/fstab' 'etc/shells' 'etc/profile'
        etc/bash.bash{rc,_logout} etc/skel/.bash{rc,_profile,_logout}
        etc/nsswitch.conf)
source=('bash.bash_logout'
        'bash.bashrc'
        'cmd'
        'dep-search'
        'dot.bash_logout'
        'dot.bash_profile'
        'dot.bashrc'
        'dot.inputrc'
        'dot.profile'
        'fstab'
        'msys2.ico'
        'msys2_shell.cmd'
        'msystem'
        'nsswitch.conf'
        'profile'
        'profile.lang.sh'
        'profile.tzset.sh'
        'regen-info.sh'
        'shell'
        'shells'
        'start'
        '01-devices.post'
        '03-mtab.post'
        '05-home-dir.post'
        '06-windows-files.post'
        '07-pacman-key.post'
        '08-xml-catalog.post'
        'cygwin.ldif'
        'main-config.site'
        'clang32-config.site'
        'clang64-config.site'
        'mingw64-config.site'
        'mingw32-config.site'
        'redirect-config.site')
sha256sums=('6d651f6b0b2d173961a3fa21acd9d44c783ed9cd73a031687698c8b9ed1f6dee'
            'fd1ecf1748391ace014ab8c1416451ce33eb9ed153f58b6403285d18f9961222'
            '99eae6e37081edd73b399009c85f4a67a0c14481241ee4937ab45c4178b540fb'
            'ed08a8bd0919ba29ec5dd2d0c74ba74324ca2bcbf7852354b0b6c523809029a0'
            '4330edf340394d0dae50afb04ac2a621f106fe67fb634ec81c4bfb98be2a1eb5'
            '06016b2541299e98474e945f22c675d63be67f3c6339b894bf75a1524dfa8604'
            '6e5d0460bc35a04c44740db7c9730ddf2aedac66b149374b6a8dfb5dae41edcd'
            'b896abbbd7187184045e42e2646d4cb25f5484a27558f780137c7ec9ca9bdc47'
            '50c3746d621e682e3560e1b37cc1ac5d988460064a20ed15f107c203ac5ad622'
            '9620bdf1c82ea3f14c3553c44a2006ea61ff3f5a775a2a053130a59cc186daf5'
            '7d6994d7caf52a459b562cfb0da1d758a4b7bca478d1df00de3a96686e59008e'
            'ec4996dc42c806320c24ed083fbd62320fa85c719572c8212595189ab1a72e6e'
            '3c1da9bf6ff791c32f17e49db0047b3c9cbaacd44d6d0b92696cdeacebf8f947'
            '91f1f918cf13deab0124082086e990786113b0e710dbda4678d8fc14905ad94d'
            '6cf6bb55f5a578aace121fb4d3db0e0081864f4eb70c1f6079ea57e3ad86540b'
            '67e9285cdadb484ccf7e189f0872d2282171de2da4796e63471471ca37cf01c5'
            '7a844eb4cb915b91c3d4a5ec6bb4ba9253b7446aac698fe7689855341b381eaa'
            '756df34c5b28478a81331785de0f56438bb652cf5f29029a9db2d83281361340'
            '2087410bf7ead6fa586628ea7fc97c53f5ea3ce16d1ee91ecc15ccc18ab53094'
            'f63241cc56aa7b7ec6962d19991d211b4e1641b78ba5226835118ab493830a8b'
            'e96c1f54ffff792e738aa032815c82c30821b0683806e5ed0ba2a759db2fd494'
            '95105051d31ecbe4ace262a4496ec1055bdd14d61b7d475a771b56fe15f8ccd9'
            'd7b7eb4cd9e1f9bc227b009cdcacf700f5523ccc109fbd3c1c0331726d314c9e'
            '1e8e666115232d0abbd0754d42aaf5756c81c5ec36b2f87264c99203aea89d1b'
            'fedaf4d9ae282f6c1698d04d280dd48c8d3247321a5cb5e309e61e2c655102c6'
            'fd6eb255b5a35e62a34a54bf39598134296a11bddd3e6a30edd008cbe136b9f3'
            'ad8533809ea2b1bce0a41b3a0a24dbc7a9f58b992ceb40cc9f862b1978032790'
            'b9af554432605fe4027fbc231170e01edb5bcbb958bfd0922609f1901a2dd555'
            '475d79aa6d4cec9f286762d0be1a0ef7c849091ddde24d2e834d186053644eed'
            'a81da3a792bc0eed2149b18fad6680207ce7a902613323aeb18f83271de54142'
            '50d50db353671ae1bf78e10ad90f2b86c15dc8ae132c5142e409ad541e24edc3'
            'c8221dce8415f3a000b4068dca9b6f8ab1944a40e7881789ead4ba54cb901bc9'
            '2ed001d7a1e1d7b3f53d2cd8f4a8b335bfef77ed3bce14558ef5aa1f46a846f0'
            '26bf8d1acade9431d60c035a7ddfa9cb0775d5b9a457c5aca56f51c5f2f93f98')

build() {
  cd ${srcdir}
}

package() {
  cd ${pkgdir}

  # setup root filesystem
  #
  for d in dev etc home usr var opt mingw32 mingw64 clang32 clang64; do
    install -d -m755 ${d}
  done

  mkdir -p tmp

  # setup /etc
  #
  install -d etc/{fstab.d,skel,profile.d,post-install}
  for f in bash.bashrc bash.bash_logout fstab shells profile nsswitch.conf msystem; do
    install -m644 ${srcdir}/${f} etc/
  done

  for f in ${srcdir}/*.post; do
    install -m644 ${f} etc/post-install/
  done

  # user configuration file skeletons
  #
  install -m644 ${srcdir}/dot.bashrc etc/skel/.bashrc
  install -m644 ${srcdir}/dot.inputrc etc/skel/.inputrc
  install -m644 ${srcdir}/dot.bash_profile etc/skel/.bash_profile
  install -m644 ${srcdir}/dot.bash_logout etc/skel/.bash_logout
  install -m644 ${srcdir}/dot.profile etc/skel/.profile

  install -m644 ${srcdir}/profile.tzset.sh etc/profile.d/tzset.sh
  install -m644 ${srcdir}/profile.lang.sh etc/profile.d/lang.sh

  install -m644 ${srcdir}/msys2.ico msys2.ico
  install -m755 ${srcdir}/msys2_shell.cmd msys2_shell.cmd

  # setup /var
  #
  for d in cache/man local opt log/old lib/misc empty; do
    install -d -m755 var/${d}
  done
  mkdir -p var/tmp

  # setup /usr
  #
  for d in bin include lib share/misc src; do
    install -d -m755 usr/${d}
  done
  for d in $(seq 8); do
    install -d -m755 usr/share/man/man${d}
  done
  # various shell scripts
  for f in cmd start dep-search regen-info.sh shell; do
    install -m755 ${srcdir}/${f} usr/bin
  done

  # setup /mingw hierarchies
  #
  for m in mingw32 mingw64 clang32 clang64; do
    for d in bin etc include lib share; do
      install -d -m755 ${m}/${d}
    done
  done

  install -Dm 644 ${srcdir}/cygwin.ldif usr/share/Msys/cygwin.ldif

  # setup 'configure' helpers
  #
  install -m644 ${srcdir}/main-config.site etc/config.site
  install -m644 ${srcdir}/clang32-config.site clang32/etc/config.site
  install -m644 ${srcdir}/clang64-config.site clang64/etc/config.site
  install -m644 ${srcdir}/mingw64-config.site mingw64/etc/config.site
  install -m644 ${srcdir}/mingw32-config.site mingw32/etc/config.site
  install -D -m644 ${srcdir}/redirect-config.site usr/local/etc/config.site
}
